package com.definesys.smecrailtransit.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.definesys.smecrailtransit.SmecApplication;
import com.definesys.smecrailtransit.service.Notification.NotificationService;

/**
 * Created by xupeizuo on 2017/7/21.
 */

public class NetWorkReceiver extends BroadcastReceiver {

    private String TAG=this.getClass().getSimpleName();

    private String power_change_action="android.net.conn.CONNECTIVITY_CHANGE";

    @Override
    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().equals(power_change_action)) {
            if(!SmecApplication.isServiceWork(SmecApplication.getContext(),"com.definesys.smecrailtransit.service.Notification.NotificationService")){
                Log.e(TAG, "BootBroadcastReceiver onReceive(), Do thing!");
                Intent service = new Intent(context, NotificationService.class);
                context.startService(service);
            }
        }
    }
}
